﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shape.Mvp.Commands;
using System.Diagnostics.Contracts;
using Shape.Mvp.Sample.Presenters;
using System.Windows.Forms;

namespace Shape.Mvp.Sample.Commands
{
	public class ShowExerciseDetailsCommand : ICommand<ShowExerciseDetailsArgument>
	{
		private IApplicationController _applicationController;
		private ExerciseDetailPresenter _presenter;

		public ShowExerciseDetailsCommand(
			IApplicationController applicationController, 
			ExerciseDetailPresenter presenter)
		{
			Contract.Requires(applicationController != null);
			Contract.Requires(presenter != null);

			_applicationController = applicationController;
			_presenter = presenter;
		}

		public void Execute(ShowExerciseDetailsArgument arg)
		{
			_presenter.Initialise(arg.Id);
				
			_applicationController.Show(_presenter.View).AsDialog();
		}
	 }
}
